/**
 * In me the tiger sniffs the rose.
 *
 * @Author:徐家政
 * @Date:2019-04-18 15:54
 */
package com.shiyu.demo.service.impl;

import com.shiyu.demo.entity.*;
import com.shiyu.demo.mapper.PostCommentMapper;
import com.shiyu.demo.mapper.PostImgMapper;
import com.shiyu.demo.mapper.PostInfoMapper;
import com.shiyu.demo.service.PostInfoService;
import com.shiyu.demo.util.R;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class PostInfoServiceImpl implements PostInfoService {
    @Resource
    private PostInfoMapper postInfoMapper;
    @Resource
    private PostImgMapper postImgMapper;
    @Resource
    private PostCommentMapper postCommentMapper;
    @Override
    public R getPostInfo(Integer postId) {
        PostInfo postInfo=postInfoMapper.getPostInfo(postId);
        PostImgExample postImgExample=new PostImgExample();
        postImgExample.createCriteria().andPostidEqualTo(postId);
        List<PostImg>postImgList=postImgMapper.selectByExample(postImgExample);

        return R.ok().put("postInfo",postInfo).put("postImgList",postImgList);

    }
}
